{template head}
<script type="text/javascript" src="{STATICDIR}third/plupload/plupload.full.min.js"></script>
<style>
	.layui-layedit{margin-left: 150px;background-color:white}
</style>

<script>
var layedit;
var indexs;
layui.use('layedit', function(){
  layedit = layui.layedit;
  
  layedit.set({uploadImage:{url:'{SITE_URL}ajax/object.php',type: 'post'}});
  
  indexs = layedit.build('content',{tool: [
  'strong' //加粗
  ,'italic' //斜体
  ,'underline' //下划线
  ,'del' //删除线
  
  ,'|' //分割线
  
  ,'left' //左对齐
  ,'center' //居中对齐
  ,'right' //右对齐
  ,'link' //超链接
  ,'unlink' //清除链接
  ,'image' //插入图片
]}); //建立编辑器
});

function submitcheck()
{
	return true;
}

function saveInfo()
{
	if(!submitcheck())
	{
		return;
	}
	
	layedit.sync(indexs);
	
	var url = '{SITE_URL}ajax/index.php?m=saveTouzi';
	
	var data = $('#savedata').serialize();
		
	var callback = function(data)
	{
		if(data.sign == -2)
		{
			window.location = data.url;
		}
		else
		{
			if(data.sign == 1)
			{
				//添加成功,返回列表页
				layer.alert(data.msg,function(){
					window.location = $('#gotoList').attr('href');
				});
			}
			else
			{
				if(data.msg)
				{
					layer.msg(data.msg);
				}
				else
				{
					layer.msg('操作失败');
				}
			}
		}
	};
	makeAjax('post',url,data,callback);
}

</script>
<body>
<div class="wrapper">
	<div class="crumbs"><a href="javascript:;">{$fTitle}</a> &gt;<a id="gotoList" href="{SITE_URL}index.php?a=tzglM&m=list">{$sTitle}</a> &gt; <span>{$pagetitle}</span> </div>
	
	<div class="container_tit clearfix mb20 ft14">
	
	<form id="savedata">
		<input type="hidden" name="id" value="{$touzi[id]}" />
		<h2 class="form_tit">
			投资攻略信息
			<a style="float:right;font-size:13px;" href="javascript:history.go(-1);">返回</a>
		</h2>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">标题：</label>
				<input placeholder="20个字以内" type="text" id="title" name="title" value="{$touzi[title]}" class="text w340" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">副标题：</label>
				<textarea class="text w340" style="height:70px" name="desc">{$touzi[desc]}</textarea>
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">列表图片：</label>
				<a id="btn1" href="javascript:;" class="btnyellow mr15">上传文件</a>
			</p>
			<p class="clearfix" style="padding-top: 10px;">
				<label class="name"></label>
				<img id="i_fengmian" src="{if !empty($touzi[fengmian])}{OSS_URL}{$touzi[fengmian]}{/if}"  style="max-width: 65px;height: 40px;" />
				<input type="hidden" id="fengmian" name="fengmian" value="{$touzi[fengmian]}" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">视频文件：</label>
				<a id="btn2" href="javascript:;" class="btnyellow mr15">上传文件</a>
			</p>
			<p class="clearfix" style="padding-top: 10px;">
				<label class="name"></label>
				<video id="v_video" controls preload="auto" width=300 height="165" 
			    	src="{if !empty($touzi[video])}{OSS_URL}{$touzi[video]}{/if}">
			    </video>
			    <input type="hidden" id="video" name="video" value="{$touzi[video]}" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">音频文件：</label>
				<a id="btn3" href="javascript:;" class="btnyellow mr15">上传文件</a>
			</p>
			
			<p class="clearfix" style="padding-top: 10px;">
				<label class="name"></label>
				<video id="a_audio" controls preload="auto" width=300 height="165" 
			    	src="{if !empty($touzi[audio])}{OSS_URL}{$touzi[audio]}{/if}">
			    </video>
			    <input type="hidden" id="audio" name="audio" value="{$touzi[audio]}" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">图片文件：</label>
				<a id="btn4" href="javascript:;" class="btnyellow mr15">上传文件</a>
				
			</p>
			<p class="clearfix" style="padding-top: 10px;">
				<label class="name"></label>
				<img id="i_img" src="{if !empty($touzi[img])}{OSS_URL}{$touzi[img]}{/if}"  style="max-width: 65px;height: 40px;" />
				<input type="hidden" id="img" name="img" value="{$touzi[img]}" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">攻略内容：</label>
				<textarea class="text w340" style="height:200px display: none;" name="content" id="content">{$touzi[content]}</textarea>
			</p>
		</div>
		
        <div class="form_item clearfix" style="padding-top: 20px;>
			<p class="clearfix">
			    <input type="button" class="btnblue" value="提交" onclick="saveInfo();" />
			</p>
		</div>
    </form>
    </div>
</div>
</body>
</html>


<script>
    var uploader1 = new plupload.Uploader({//创建实例的构造方法
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: 'btn1', // 上传按钮
        url: "{SITE_URL}ajax/object.php", //远程上传地址
        flash_swf_url: '{STATICDIR}plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: '{STATICDIR}plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '5mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        init: {
            FilesAdded: function(up, files) { //文件上传前
                if ($("#ul_pics").children("li").length > 30) {
                    ts("您上传的图片太多了！");
                    uploader1.destroy();
                } else {
                    var li = '';
                    plupload.each(files, function(file) { //遍历文件
                        li += "<li id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></li>";
                    });
                    $("#ul_pics").append(li);
                    uploader1.start();
                }
            },
            UploadProgress: function(up, file) { //上传中，显示进度条
         	var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发
	               var data = eval("(" + info.response + ")");
	               
	                var picurl = '{OSS_URL}';
	                $("#i_fengmian").attr('src',picurl+data.name);
	                $("#fengmian").val(data.name);
	            },
            Error: function(up, err) { //上传出错的时候触发
                layer.msg(err.message);
            },
            UploadComplete:function()
            {
            	layer.msg('上传成功');

            	//window.location = window.location;
            }
        }
    });
    uploader1.init();
    
    var uploader2 = new plupload.Uploader({//创建实例的构造方法
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: 'btn2', // 上传按钮
        url: "{SITE_URL}ajax/object.php", //远程上传地址
        flash_swf_url: '{STATICDIR}plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: '{STATICDIR}plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '50mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "mp4"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        init: {
            FilesAdded: function(up, files) { //文件上传前
                if ($("#ul_pics").children("li").length > 30) {
                    ts("您上传的图片太多了！");
                    uploader2.destroy();
                } else {
                    var li = '';
                    plupload.each(files, function(file) { //遍历文件
                        li += "<li id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></li>";
                    });
                    $("#ul_pics").append(li);
                    uploader2.start();
                }
            },
            UploadProgress: function(up, file) { //上传中，显示进度条
         	var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发
	               var data = eval("(" + info.response + ")");
	               
	                var picurl = '{OSS_URL}';
	                $("#v_video").attr('src',picurl+data.name);
	                $("#video").val(data.name);
	              //  _upload_callback(data.name,data.size);
	            },
            Error: function(up, err) { //上传出错的时候触发
                layer.msg(err.message);
            },
            UploadComplete:function()
            {
            	layer.msg('上传成功');

            	//window.location = window.location;
            }
        }
    });
    uploader2.init();
    
    var uploader3 = new plupload.Uploader({//创建实例的构造方法
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: 'btn3', // 上传按钮
        url: "{SITE_URL}ajax/object.php", //远程上传地址
        flash_swf_url: '{STATICDIR}plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: '{STATICDIR}plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '20mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "mp4,mp3"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        init: {
            FilesAdded: function(up, files) { //文件上传前
                if ($("#ul_pics").children("li").length > 30) {
                    ts("您上传的图片太多了！");
                    uploader3.destroy();
                } else {
                    var li = '';
                    plupload.each(files, function(file) { //遍历文件
                        li += "<li id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></li>";
                    });
                    $("#ul_pics").append(li);
                    uploader3.start();
                }
            },
            UploadProgress: function(up, file) { //上传中，显示进度条
         	var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发
	               var data = eval("(" + info.response + ")");
	               
	                var picurl = '{OSS_URL}';
	                $("#d_audio").attr('src',picurl+data.name);
	                $("#audio").val(data.name);
	              //  _upload_callback(data.name,data.size);
	            },
            Error: function(up, err) { //上传出错的时候触发
                layer.msg(err.message);
            },
            UploadComplete:function()
            {
            	layer.msg('上传成功');

            	//window.location = window.location;
            }
        }
    });
    uploader3.init();
    
    var uploader4 = new plupload.Uploader({//创建实例的构造方法
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: 'btn4', // 上传按钮
        url: "{SITE_URL}ajax/object.php", //远程上传地址
        flash_swf_url: '{STATICDIR}plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: '{STATICDIR}plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '5mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        init: {
            FilesAdded: function(up, files) { //文件上传前
                if ($("#ul_pics").children("li").length > 30) {
                    ts("您上传的图片太多了！");
                    uploader4.destroy();
                } else {
                    var li = '';
                    plupload.each(files, function(file) { //遍历文件
                        li += "<li id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></li>";
                    });
                    $("#ul_pics").append(li);
                    uploader4.start();
                }
            },
            UploadProgress: function(up, file) { //上传中，显示进度条
         	var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发
	               var data = eval("(" + info.response + ")");
	               
	                var picurl = '{OSS_URL}';
	                $("#i_img").attr('src',picurl+data.name);
	                $("#img").val(data.name);
	              //  _upload_callback(data.name,data.size);
	            },
            Error: function(up, err) { //上传出错的时候触发
                layer.msg(err.message);
            },
            UploadComplete:function()
            {
            	layer.msg('上传成功');

            	//window.location = window.location;
            }
        }
    });
    uploader4.init();
</script>